package net.killerscape.packethandler;

import net.killerscape.model.Player;
import net.killerscape.net.Packet;
import net.killerscape.util.Logger;
import org.apache.mina.common.IoSession;

public class ItemClicked implements PacketHandler {
	public void handlePacket(Packet p, IoSession session) {
		Player player = (Player) session.getAttachment();
		switch(p.getId()) {
		
			case 3:
				int slotid = p.readShort();
				int frameid = p.readShort();
				int itemid = p.readUnsignedWordBigEndian();
				System.out.println("RAWR - "+frameid+" and "+itemid+" and "+slotid);
/*
				case 30235:
					System.out.println("RAWR - "+frameID+" and "+itemID+" and "+slotID);
					if(player.getEquipment().isEquipped(3))
						player.getEquipment().unequipItem(3);
					break;
				case 46864:
					System.out.println("RAWR - "+frameID+" and "+itemID+" and "+slotID);
					if(player.getEquipment().isEquipped(3))
						player.getEquipment().unequipItem(3);
					break;
				default:
					Logger.err("Unhandled item click in frame: "+frameID);*/
				break;
			
			case 24:		
				int frameID = p.readUnsignedWordBigEndian();
				int itemID = p.readUnsignedWordBigEndian();
				int slotID = p.readUnsignedWordA();
				switch(frameID) {
					case 3214:
						if(player.getInventory().playerHasItemInSlot(itemID, slotID))
							player.getEquipment().equipItem(3, itemID, slotID);
						else
							Logger.err("Injected packets - player tried cheating.");
						break;
				}
				
				break;
		}
		/*System.out.println("Equiping: "+itemID);
		player.getEquipment().equipItem(3, itemID, 1);
		if(frameID == Inventory.FRAME && player.getInventory().getFrameInUse() == Inventory.BANK_FRAME) {
			player.getInventory().removeItemAtSlot(slotID);
			player.getBank().addItem(itemID, 1);
		}*/
	}
}